// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App.vue'
import router from './router'
//引入elementui
import ElementUi from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import iView from 'iview';//引入iview
import 'iview/dist/styles/iview.css';
// import '../static/css/index.scss'//cms样式
// console.log(iView)
Vue.use(ElementUi);
//引入Vuex
import Vuex from 'vuex'
import store from './store/store.js'
Vue.use(Vuex);
import interfaceUrl from './url'
Vue.prototype.interfaceUrl = interfaceUrl


Vue.use(iView)
//引入axios
import axios from 'axios'
Vue.prototype.axios = axios;
// Vue.prototype.$http = axios
//引用mockjs
require ('./mock.js')
Vue.prototype.$time = (d)=>{
  let t = new Date(d);
  return t.getFullYear()+'-'+(t.getMonth()<9?'0':'')+(t.getMonth()+1)+'-'+(t.getDate()<10?'0':'')+t.getDate()+" " +(t.getHours()<10?"0":"")+t.getHours()+":"+(t.getMinutes()<10?'0':'')+t.getMinutes()+":"+(t.getSeconds()<10?'0':'')+t.getSeconds()
}
import echarts from 'echarts'
Vue.prototype.echarts = echarts;

Vue.prototype.$millisecond = (d)=>{
  /*if(d<1000 && d>=0){
    return d +" 毫秒"
  }else if(d<0){
    return "0 毫秒"
  }else if(d>=1000 && d<60000){
    let s=parseInt(d/1000);
    let v=d%1000;
    if(v == 0){
      return s +"秒"
    }else{
      return s +"秒"+ v +"毫秒"
    }
  }else if(d>=60000 && d<3600000){
    let m=parseInt(d/60000);//分
    let i=d%60000;//秒
    let s=parseInt(i/1000);
    let v=s%1000;
    if (v == 0 && i!=0) {
      return m+"分"+i +"秒"
    }else if (v==0 && i==0){
      return m+"分"
    }else if (v!=0 && i==0){
      return m+"分"+v +"毫秒"
    }else{
      return m+"分"+i +"秒"+v +"毫秒"
    }
  }else{
    let h=parseInt(d/3600000);//时
    let z=d%3600000;
    let m=parseInt(z/60000);//分
    let i=d%60000;
    let s=parseInt(i/1000);//秒
    let v=s%1000;
    return h+"小时"+m+"分"+s +"秒"+v +"毫秒"
  }*/
  let days = Math.floor(d / (1000 * 60 * 60 * 24));
  let hours = Math.floor((d % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  let minutes = Math.floor((d % (1000 * 60 * 60)) / (1000 * 60));
  let seconds = Math.floor((d % (1000 * 60)) / 1000);
  let miseconds;
  if(d < 1000)
    miseconds = d;
  else
    miseconds = (d % (1000 * 60)) / 1000 * 1000 - seconds*1000;
  let tmpTime = "";
  if(days != 0)
    tmpTime+= days + "天";
  if(hours != 0)
    tmpTime+= hours + "小时";
  if(minutes != 0)
    tmpTime+= minutes + "分";
  if(seconds != 0)
    tmpTime+= seconds + "秒";
  if(miseconds != 0)//可能出现带小数点，取附近的整数
    tmpTime+= Math.round(miseconds) + "毫秒";
  if(d < 0)
    tmpTime = "进行中";
  return tmpTime;
};

Vue.config.productionTip = false;

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
